package Test;

import java.util.Iterator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import org.codehaus.jackson.JsonNode;

import com.sun.jersey.api.client.Client;

import nl.tue.be.ds.duraark.bSDD.ClientUtilities;
import nl.tue.be.ds.duraark.bSDD.DataBaseStorageUnit;
import nl.tue.be.ds.duraark.bSDD.DataBaseUtilities;
import nl.tue.be.ds.duraark.bSDD.dump.ConSearchPerTermPatternCallable;

public class TestMain {

	public static void main(String[] args) throws Exception {
		/*TestSearchPerGuid  tspg = new TestSearchPerGuid();
		tspg.searchPerGuid();*/
		/*DumpPerTermPatternCallable dptc = new DumpPerTermPatternCallable("wall", false);
		ExecutorService pool = Executors.newSingleThreadExecutor();
		Future<Integer> future = pool.submit(dptc);
		
		System.out.println(future.get());
		DataBaseUtilities.db.close();
		pool.shutdown();*/
		
	/*	ClientUtilities.getCookies().get(0);
		ClientUtilities.getClient();
		ClientUtilities.getCookies(ClientUtilities.getClient()).get(0);
		ClientUtilities.getClient();
		Client client = ClientUtilities.getClient();
		ClientUtilities.getCookies(client).get(0);
		ClientUtilities.getClient();
		ClientUtilities.getCookies().get(0);*/
		
		DataBaseStorageUnit dumpStorageUnit = DataBaseUtilities.getDumpedDBSunitPerGuid("3xutUAsQCHu000025QrE$V", DataBaseUtilities.db);
		
		JsonNode jsonNode = dumpStorageUnit.getConceptJN();
		System.out.println(DataBaseUtilities.isConceptExistedInDB(jsonNode, DataBaseUtilities.db));
		System.out.println("conceptType: " + jsonNode.get("conceptType"));
		System.out.println("fullNames: " + jsonNode.get("fullNames"));
		System.out.println("definitions-->description: " + jsonNode.get("definitions").get("description"));
		
		if (dumpStorageUnit.getParentsGuidMap()== null)
		System.out.println("No parents rels");
	else{
		Iterator<String> iter = dumpStorageUnit.getParentsGuidMap().keySet().iterator();
		while(iter.hasNext()){
			String conceptGuid = (String) iter.next();
			System.out.println("Parents rels: "+ conceptGuid + "<---->" + dumpStorageUnit.getParentsGuidMap().get(conceptGuid));
		}
	}
	if (dumpStorageUnit.getChildrenGuidMap()== null)
		System.out.println("No children rels");
	else
	{
		Iterator<String> iter = dumpStorageUnit.getChildrenGuidMap().keySet().iterator();
		while(iter.hasNext()){
			String conceptGuid = (String) iter.next();
			System.out.println("Children rels: "+ conceptGuid + "<---->" + dumpStorageUnit.getChildrenGuidMap().get(conceptGuid));
		}
	}
		
		DataBaseUtilities.db.close();
		
		
		
		
	}

}
